package app.web.galgame.cgs.auto;

import java.io.File;

import cn.lily.com.enviroment.Enviroment;
import cn.lily.com.lang.BusinessDate;

/**
 * 自动采集处理
 * @author JiaJ
 *
 */
public class GalAutoCollect {
	
	private String analysePath = "H:/待处理/ANLYSE/Orginal";
	
	public void analyse() {
		
		File folder = new File(this.analysePath);
		
		File[] childFolders = folder.listFiles();
		for(File childFolder:childFolders){
			
			String name = childFolder.getName();
			String date = BusinessDate.getdayNumber();
			for(File file:childFolder.listFiles()){
				
				String dateName = file.getName();
				if(dateName.endsWith(".date")){
					String tmpName = dateName.substring(0,6);
					if(tmpName.startsWith("9") || tmpName.startsWith("8")){
						date = "19" + tmpName;
					}else{
						date = "20" + tmpName;
					}
					
					if(date.equals("20000000")){
						date = "20000101";
					}
					
					break;
				}
				
			}
			
			Enviroment.getEnv().getLogBean().beginLog();
			
			GalAutoCollectDetail detail = new GalAutoCollectDetail();
			detail.setFileName(name);
			detail.setFileDate(date);
			detail.setFolder(childFolder);
			
			detail.analyse();
			
			Enviroment.getEnv().getLogBean().endLog();
	
		}
		
	}
	
		
	public static void main(String[] args) {
		
		Enviroment.createEnv();		
		Enviroment.getEnv().getLogBean().beginLog();
		
		GalAutoCollect collect = new GalAutoCollect();
		collect.analyse();
		
		System.out.println("分析结束...........");
		
		Enviroment.getEnv().getLogBean().endLog();
		
	}

}
